<template>
  <div>
    <a-card :bordered="false" class="mb15 searchCard">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="10" :lg="7" :md="8" :sm="24">
              <a-form-item label="用户名">
                <a-input placeholder="请输入用户名" v-model="queryParam.userName"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="10" :lg="7" :md="8" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- 查询区域-END -->
    </a-card>
    <a-card :bordered="false">
      <!-- table区域-begin -->
      <div>
        <a-table
          ref="table"
          :scroll="{x:true}"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :loading="loading"
          class="j-table-force-nowrap"
        >
          <span slot="action" slot-scope="text, record">
            <a @click="kickOut(record)">强制下线</a>
          </span>
        </a-table>
      </div>
    </a-card>
  </div>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { KsListMixin } from '@/mixins/KsListMixin'
import SysIndustryModal from './modules/SysIndustryModal'
import JSuperQuery from '@/components/ksource/JSuperQuery.vue'
import { postAction } from '@/api/manage'

export default {
  name: 'SysIndustryList',
  mixins:[KsListMixin, mixinDevice],
  components: {
    SysIndustryModal,
    JSuperQuery,
  },
  data () {
    let that=this
    return {
      description: '行业类别管理页面',
      sn:0,
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            that.sn=that.ipagination.total
            return (that.ipagination.current-1)*that.ipagination.pageSize+parseInt(index) + 1;
          }
        },
        {
          title:'用户名',
          align:"center",
          dataIndex: 'sysUser',
          customRender: function (t, r, index) {
            return t.username+"/"+t.realname
          }
        },
        {
          title: 'ip',
          dataIndex: 'ip',
          align:"center",
        },
        {
          title: '登陆时间',
          dataIndex: 'loginDate',
          align:"center",
        },
        {
          title: '登录设备',
          dataIndex: 'browser',
          align:"center",
        },
        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          width:147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      /* 排序参数 */
      isorter:{
        column: 'sn',
        order: 'asc',
      },
      url: {
        list: "/platform/system/sysUser/getOnlineUser",
        kickOut: "/platform/system/sysUser/kickOut",
      },
      dictOptions:{},
      superFieldList:[],
      param:{}
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig(){
    },
    getSuperFieldList(){
      let fieldList=[];
      fieldList.push({type:'string',value:'name',text:'行业名称'})
      this.superFieldList = fieldList
    },
    kickOut(record){
      this.param.kick=record.token
      postAction(this.url.kickOut,this.param).then((res) => {
        if (res.success) {
          this.$message.success(res.message);
          this.loadData();
        } else {
          this.$message.warning(res.message);
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
